package com.example.rabbitmq;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Project:spring-boot-rabbitmq
 * <p>
 * Title:RabbitMqMessageProducer.java
 * <p>
 * Description:
 * <p>
 * Copyrigth:Jiang Software LTD.co Copyright (c) 2021
 * <p>
 * 
 * @version 1.0
 * @since 1.8
 * @author jiang
 * @history 2021 jiang create
 */

@Service
public class MessageProducer {

	@Autowired
	private RabbitTemplate rabbitTemplate;

	/**
	 * 消息发送，将交换机和路由器进行绑定
	 *
	 * @param msg
	 */
	public void send(String msg) {
		this.rabbitTemplate.convertAndSend(RabbitMqConfig.EXCHANGE, RabbitMqConfig.ROUTINGKEY, msg);
	}

}
